package com.meiyou.service.impl;

import java.util.Random;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.meiyou.mapper.MeiyouUserMapper;
import com.meiyou.service.AliYunService;
import com.meiyou.utils.ApiUtil;
import com.meiyou.utils.Msg;

@Service
public class AliYunServiceImpl implements AliYunService{
    
	@Autowired
	MeiyouUserMapper usermapper;
	
	
	public Msg sendMsg(String phone,int msgtype,HttpServletRequest req) {
		// TODO Auto-generated method stub
		
		String verifyCode = String.valueOf(new Random().nextInt(899999) + 100000);//验证码
		System.out.println("发送验证码："+verifyCode);
		if(msgtype==1) {
			String qianming = "美游";
			String templatecode = "SMS_163675061";
			String templateparam = "{\"code\":\""+verifyCode+"\"}";
			Msg msg = ApiUtil.aliYunMsg(phone, verifyCode, qianming, templatecode, templateparam,req);
			return msg;
		}
		else if(msgtype==2){
			String qianming = "美游";
			String templatecode = "SMS_163675063";
			String templateparam = "{\"code\":\""+verifyCode+"\"}";
			Msg msg = ApiUtil.aliYunMsg(phone, verifyCode, qianming, templatecode, templateparam, req);
			return msg;
		}
		else {
			return null;
		}
	}
}
